package com.glory.cqaospda.viewmodel

import com.glory.cqaospda.model.TaskRepository
import com.glory.mvvmnet.base.BaseViewModel
import com.glory.mvvmnet.entity.CallObserveBean
import com.google.gson.JsonObject

class PartsModel:BaseViewModel() {

    private val repository by lazy { TaskRepository() }

    fun defaultEqpInfo(eqpID: String,waitType:String) {
        val map = JsonObject()
        map.addProperty("EquipmentName", eqpID)
        map.addProperty("WaitType", waitType)
        launchOnlyResult({
            val defaultEqpInfo =
                repository.defaultWaitMaterialInfo(map,"EMS_WaitMaterialInfo")
            defUI.callObserve.value = CallObserveBean(1,defaultEqpInfo)
        })
    }

    fun defaultWaitMaterial(map : JsonObject) {
        launchOnlyResult({
            repository.defaultWaitMaterial(map,"EMS_WaitMaterial")
            defUI.callObserve.value = CallObserveBean(2)
        })
    }

    fun defaultGetBaseConfig(){

        val map = JsonObject()
        map.addProperty("GroupID", "parts_type")

        launchOnlyResult({
            val baseConfigBean =
                repository.defaultGetBaseConfig(map,"EMS_GetBaseConfig")
            defUI.callObserve.value = CallObserveBean(3,baseConfigBean)
        })
    }

    fun defaultGetPartsName(){

        val map = JsonObject()
        map.addProperty("GroupID", "PartsName")

        launchOnlyResult({
            val baseConfigBean =
                repository.defaultGetBaseConfig(map,"EMS_GetBaseConfig")
            defUI.callObserve.value = CallObserveBean(4,baseConfigBean)
        })
    }

}